<template>
<div class="cal">
  <h3>新增名片</h3>
  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="姓名">
      <el-input v-model="form.name"></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="form.sex">
        <el-radio label="男"></el-radio>
        <el-radio label="女"></el-radio>
      </el-radio-group>
    </el-form-item>

    <el-form-item label="生日">
      <el-col :span="11">
        <el-date-picker type="date" placeholder="选择日期" v-model="form.birthday" style="width: 100%;"></el-date-picker>
      </el-col>
      <el-col class="line" :span="2">-</el-col>
    </el-form-item>
    <el-form-item label="公司">
      <el-input v-model="form.company"></el-input>
    </el-form-item>
    <el-form-item label="职位">
      <el-input v-model="form.position"></el-input>
    </el-form-item>
    <el-form-item label="手机号">
      <el-input v-model="form.mobile"></el-input>
    </el-form-item>



    <el-form-item>
      <el-button type="primary" @click="onSubmit">添加</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</div>
</template>

<script>
export default {
  name: "CardAdd",
  data() {
    return {
      form: {
        name: '',
        sex: '',
        birthday: '',
        company: '',
        position: '',
        mobile: '',

      }
    }
  },
  methods: {
    onSubmit() {
      let vm =this;
      this.axios({
        url:"http://localhost:8888/card/add",
        method:"post",
        data:vm.form
      }).then(function (res) {
        if (res.data.code==0){
          vm.$message.success('名片添加成功');
          setTimeout(function () {
            vm.$router.push('card');
          }, 1000);
        }
      })
    }
  }
}
</script>

<style scoped>
.cal{
  width: 400px;
  margin: 0px auto;

}
</style>
